package vanjalee.bs.com.control.csv;

import org.supercsv.cellprocessor.CellProcessorAdaptor;
import org.supercsv.cellprocessor.ift.CellProcessor;
import org.supercsv.util.CsvContext;

import vanjalee.bs.com.control.model.ItemType;

public class ParseItemType extends CellProcessorAdaptor {

	public ParseItemType() {
		super();
	}

	public ParseItemType(CellProcessor next) {
		super(next);
	}

	public Object execute(Object value, CsvContext context) {
		if (value != null)
			for (ItemType itemType : ItemType.values()) {
				if (itemType.name().equalsIgnoreCase(value.toString())) {
					return next.execute(itemType, context);
				}
			}
		return null;		
	}
}